package com.ecp.commons.db;

import java.io.Serializable;
import java.util.List;

import org.json.JSONArray;
import org.json.JSONObject;

import com.ecp.commons.bean.Page;

public interface GenericService<T> extends Generic<T> {
	int generateId() throws Exception;

	void delete(Serializable pk) throws Exception;

	void deleteBatch(List<?> pks, boolean inTrans) throws Exception;

	T load(Serializable pk) throws Exception;

	T getEntity(String sql, Object[] args) throws Exception;

	T getEntity(String[] keys, Object[] args) throws Exception;

	List<T> getAll() throws Exception;

	List<T> getEntityList(String sql, Object[] args) throws Exception;

	List<T> getEntityList(String[] keys, Object[] args, Page page) throws Exception;

	int execute(String sql, Object[] args);

	JSONObject toJSON(T t, String[] keys);

	JSONObject toJSON(T t, String[] keys, String prefix);

	JSONArray toJSONArray(List<T> list, String keys[]);

	T fromJSON(JSONObject jobj);

	List<T> fromJSONArray(JSONArray jarr);
	
	T copy(T t);
}
